import CryptoJS from './aes.js'
var IV = '1234567890123412'
var KEY = '201707eggplant99'
const crypt = {
  encrypt: function(str) {
    var key = CryptoJS.enc.Utf8.parse(KEY)
    var iv = CryptoJS.enc.Utf8.parse(IV)
    var encrypted = CryptoJS.AES.encrypt(str, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 })
    return encrypted.toString()
  },
  decrypt: function(str) {
    var key = CryptoJS.enc.Utf8.parse(KEY)
    var iv = CryptoJS.enc.Utf8.parse(IV)
    var decrypted = CryptoJS.AES.decrypt(str, key, { iv: iv, padding: CryptoJS.pad.Pkcs7 })
    return decrypted.toString(CryptoJS.enc.Utf8)
  }
}

export default crypt
